package cn.yunhe.hui.controller;
import cn.yunhe.hui.entity.User;
import cn.yunhe.hui.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;

@RestController
public class UserController {
    @Resource
    private UserService userService;

    @RequestMapping("/toUser")
    public ModelAndView toShow() {
        return new ModelAndView("b_userlist");
    }

    @RequestMapping("/toVip")
    public ModelAndView toVipShow() {
        return new ModelAndView("b_viplist");
    }



    @RequestMapping("/getUserList")
    public Page<User> userPage(int pageNum, int pageSize, User user) {
        return userService.getUserByPage(pageNum, pageSize, user);
    }

    @RequestMapping("/getVipList")
    public Page<User> getVipList(int pageNum, int pageSize, User user) {
        return userService.getVipByPage(pageNum, pageSize, user);
    }

    @RequestMapping("/del")
    public int delUser(User user) {
        user.setState(1);
        return userService.updateById(user);
    }

    @RequestMapping("/uCount")
    public int count() {
        return userService.selectCount();
    }


}
